@extends('layouts.app')

@section('content')

    <div class="container mx-auto flex " xmlns="http://www.w3.org/1999/html">
        <div class=" w-full mt-4 ">
            <form action="/categorySearch" method="get">
                <div class="w-full">

                    <div class="card bg-base-100 p-4 flex flex-wrap  gap-4 flex-row items-center" >
                        <h3>分类筛选：</h3>
                        <button name="current" class="btn
                 @if($current == '') btn-primary @endif
                 btn-sm " value="">全部
                        </button>
                        @foreach($category as $item)
                            <button name="current" value="{{ $item->id }}" class="btn
                 @if($current == $item->id) btn-primary @endif
                 btn-sm">{{ $item->name }}</button>
                        @endforeach
                    </div>

                    <label class="input  flex items-center  flex-1 mt-4">
                        <input type="text" class="grow input-sm " value="{{ $title }}" name="title" placeholder="书名搜索"/>
                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"
                             class="w-4 h-4 opacity-70">
                            <path fill-rule="evenodd"
                                  d="M9.965 11.026a5 5 0 1 1 1.06-1.06l2.755 2.754a.75.75 0 1 1-1.06 1.06l-2.755-2.754ZM10.5 7a3.5 3.5 0 1 1-7 0 3.5 3.5 0 0 1 7 0Z"
                                  clip-rule="evenodd"/>
                        </svg>
                    </label>

                </div>
            </form>


            <div class="grid md:grid-cols-3 md:grid-cols-3 xl:grid-cols-6  gap-4 pt-4">
                @foreach($dataList as $item)
                    <a class="card w-100 bg-base-100 shadow-xl cursor-pointer " href="/book/{{ $item->id }}">
                        <figure class="relative"><img src="/{{ $item->cover }}"
                                                      alt="Shoes"/>
                            <span
                                class="inline text-md absolute bottom-0 left-0  rounded-r  bg-green-500 text-white px-2 py-1"># {{ $item->category->name }}</span>
                            <span
                                class="inline text-md absolute bottom-0 right-0 bg-blue-500 rounded-l text-white px-2 py-1"> 余{{ $item->stock }}</span>
                        </figure>

                        <div class="card-body p-4">
                            <h2 class="text-md font-bold">{{ $item->title }}</h2>
                            <span class="text-sm">{{ $item->author }}著</span>
                            <span class="text-sm"> {{ $item->publisher }}</span>

                        </div>
                    </a>
                @endforeach


            </div>


        </div>


    </div>

    <div class="flex justify-center mt-6">
        {{ $dataList->links() }}
    </div>


    @if(count($dataList) == 0)
        @include('tool.empty')
    @endif
@endsection
